from django.template import RequestContext
from django.shortcuts import render_to_response
from django.conf import settings

from pacs.models import Task,ProblemDescription

def show_task(request,task_slug):
	
	c = RequestContext(request)
	task = Task.objects.get(slug=task_slug)
	try:
		description = task.problem.get_description(c['LANGUAGE_CODE'])
	except ProblemDescription.DoesNotExist:
		try:
			description = task.problem.description_set.get(lang = settings.LANGUAGE_CODE)
		except ProblemDescription.DoesNotExist:
			description = None
	c['task'] = task
	c['description'] = description

	return render_to_response('pacs/show_task.xhtml',c)
